import request from '@/utils/request';
/**
 * 查询当前任务关联合同
 */
export function getTaskContract(params) {
    return request({
        url: '/oms/omstask/taskContract',
        method: 'get',
        params
    })
}
/**
 * 查询任务列表
 */
export function getTaskList(params) {
    return request({
        url: '/oms/omstask/list',
        method: 'get',
        params
    })
}

/**
 * 新增任务
 */
export function addTask(data) {
    return request({
        url: '/oms/omstask',
        method: 'post',
        data
    })
}

/**
 * 取消任务
 */
export function cancelTask(taskId) {
    return request({
        url: '/oms/omstask/taskCancel',
        method: 'post',
        params: {taskId}
    })
}

/**
 * 置顶/取消置顶
 */
export function toppingTask(data) {
    return request({
        url: '/oms/omstask/taskTopping',
        method: 'post',
        data
    })
}

/**
 * 根据成品编号查询产品信息
 * type 1成品;2半成品;3原材料
 */
export function getProductByNo(productNo, type) {
    return request({
        url: '/oms/product/queryProductByNo',
        method: 'get',
        params: {productNo, type}
    })
}
/**
 * 根据成品名称查询产品信息
 * type 1成品;2半成品;3原材料
 */
export function getProductByName(productName, type) {
    return request({
        url: '/oms/product/queryProductByName',
        method: 'get',
        params: {productName, type}
    })
}

/**
 * 查询任务详情
 */
export function getTaskDetail(taskId) {
    return request({
        url: `/oms/omstask/${taskId}`,
        method: 'get'
    })
}

/**
 * 查询步骤信息
 */
export function getTaskStep(taskId, type) {
    return request({
        url: '/oms/omstask/getTaskStep',
        method: 'get',
        params: {taskId, type}
    })
}

/**
 * 更新计划完成时间
 */
export function updatePlanComplete(taskId, time) {
    return request({
        url: '/oms/omstask/updateTaskDate',
        method: 'post',
        params: {taskId, time}
    })
}
/**
 * 更新交付客户
 */
export function updateDeliver(taskId, inputDeliver) {
    return request({
        url: '/oms/omstask/updateDeliver',
        method: 'post',
        params: {taskId, inputDeliver}
    })
}

/**
 * 任务详情，查询所有商品
 */
export function getAllGoodsList(params) {
    return request({
        url: '/oms/omstask/taskAllProductList',
        method: 'get',
        params
    })
}

/**
 * 任务详情，查询半成品任务
 */
export function getHalfTask(params) {
    return request({
        url: '/oms/omstask/taskProductList',
        method: 'get',
        params
    })
}

/**
 * 任务详情，查询工人业绩
 */
export function getAchievement(params) {
    return request({
        url: '/oms/achievement/list',
        method: 'get',
        params
    })
}

/**
 * 任务详情，查询任务详情备注
 */
export function getTaskDetailRemark(params) {
    return request({
        url: '/oms/taskremark/list',
        method: 'get',
        params
    })
}

/**
 * 任务详情，新增业绩
 */
export function addAchievement(data) {
    return request({
        url: '/oms/achievement/addAchievement',
        method: 'post',
        data
    })
}

/**
 * 任务详情，新增备注
 */
export function addRemark(data) {
    return request({
        url: '/oms/taskremark',
        method: 'post',
        data
    })
}

/**
 * 任务详情，新增备注
 */
export function updateRemark(data) {
    return request({
        url: '/oms/taskremark',
        method: 'put',
        data
    })
}
/**
 * 查询合同所有列表
 */
export function getContractList(params) {
    return request({
        url: '/oms/omstask/contractList',
        method: 'get',
        params
    })
}
/**
 * 查询合同所有列表
 */
export function getTaskProductListByTaskId(params) {
    return request({
        url: '/oms/taskproduct/taskProductListByTaskId',
        method: 'get',
        params
    })
}


/**
 * 提交任务操作
 */
export function taskHandle(taskId, stepId, type) {
    return request({
        url: '/oms/omstask/taskOperation/',
        method: 'post',
        params: {taskId, stepId, type}
    })
}
/**
 * 提交补数操作
 */
export function Complement(productId, complementNum, productNum,taskId,isBuShu) {
    return request({
        url: '/oms/omstask/complement/',
        method: 'post',
        params: {productId, complementNum, productNum,taskId,isBuShu}
    })
}

export default {
    addRemark, updateRemark
}
